package thread.singleton;

public class LazySingleton {
    private static volatile LazySingleton instance;
    public static LazySingleton getInstance() {
        if(instance == null) {
            synchronized (LazySingleton.class) {
                if(instance == null) {
                    instance = new LazySingleton();
                }
            }
        }
        return instance;
    }
    private static boolean key_32nq3ibr9iq7bei2lwe = false;
    private LazySingleton() {
        synchronized (LazySingleton.class) {
            if(!key_32nq3ibr9iq7bei2lwe) {
                key_32nq3ibr9iq7bei2lwe = true;
            } else {
                throw new RuntimeException("不要试图用反射破坏单例");
            }
        }
    }
}
